<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            position: absolute;
            left: 0;
            width: 200px;
            height: 200px;
            background-color: brown;
        }

        span {
            /* 动画一定要加定位 */
            position: absolute;
            left: 0;
            top: 250px;
            display: block;
            width: 150px;
            height: 150px;
            background-color: purple;
        }
    </style>
    <script  src="animate.js"></script>
</head>
<body>
    <script>
        var div = document.querySelector('div');
        var button = document.querySelector('button');
        var span = document.querySelector('span');

        button.addEventListener('click',function(){
            animate(div,500,function(){
                div.style.backgroundColor = 'skyblue';
                console.log(2222);
            });
        });
        // animate(span,300);
        animate(div,800);
    </script>
</body>
</html>